package cn.iocoder.yudao.module.product.dal.mysql.shopfavorite;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.product.controller.admin.shopfavorite.vo.ShopFavoritePageReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.shopfavorite.ShopFavoriteDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 商铺收藏 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ShopFavoriteMapper extends BaseMapperX<ShopFavoriteDO> {

    default PageResult<ShopFavoriteDO> selectPage(ShopFavoritePageReqVO reqVO, List<Long> myShopIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopFavoriteDO>()
                .in(ShopFavoriteDO::getShopId, myShopIds)
                .eqIfPresent(ShopFavoriteDO::getShopId, reqVO.getShopId())
                .betweenIfPresent(ShopFavoriteDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopFavoriteDO::getId));
    }

}